/**
 * @file ebex_mempool.h
 *
 * @date Oct 21, 2011
 * @author seth
 *
 * @brief This file is part of EBEX State Estimator, created for the EBEX project
 *
 * This software is copyright (C) 2011 Columbia University
 *
 * EBEX State Estimator is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * EBEX State Estimator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with EBEX State Estimator; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef EBEX_MEMPOOL_H_
#define EBEX_MEMPOOL_H_

#include <ebex_util.h>

#include <stdlib.h>
#include <string.h>

#include <memory_util.h>

#ifndef MEMORY_ALIGN_SIZE
#	define MEMORY_ALIGN_SIZE       MAX( 2 * sizeof(void *), 2 * sizeof(long))
#endif

/*
 * Data types.
 */

typedef struct memchunk_s memchunk_t;


void		mem_chunk_init_openmp(void);

memchunk_t	*mem_chunk_new(size_t atom_size, unsigned int num_atoms);
bool		mem_chunk_isempty(memchunk_t *mem_chunk);
void		mem_chunk_destroy(memchunk_t *mem_chunk);
void		*mem_chunk_alloc(memchunk_t *mem_chunk);
void		mem_chunk_free(memchunk_t *mem_chunk, void *mem);
void		mem_chunk_clean(memchunk_t *mem_chunk);
void		mem_chunk_reset(memchunk_t *mem_chunk);
void		mem_chunk_diagnostics_real(void);

#endif /* EBEX_MEMPOOL_H_ */
